<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/20 0020
 * Time: 19:30
 */
header("Content-Type:application/json;charset=utf-8");
if (isset($_REQUEST["pid"])) {
    $PID = $_REQUEST["pid"];
    //根据id获取指定产品
    $goodsListStr = file_get_contents("./data/goodsList.json");
    $goodListArr = json_decode($goodsListStr);

    for ($i = 0; $i < count($goodListArr); $i++) {
        if ($goodListArr[$i]->pid==$PID){
            print_r(json_encode($goodListArr[$i]));
            break;
        }
    }
} else {
    print_r(file_get_contents("./data/goodsList.json"));
}